﻿using System;
using Acaweb.Data.Contracts;
using Acaweb.Model.Entities;
using Acaweb.Model.Entities.DatosCompuestos;
using Acaweb.Componentes.Contracts;
using System.Collections.Generic;
using System.Linq;

namespace Acaweb.Componentes
{
    public class ApplicationsService : BaseService, IApplicationsService
    {
        private IApplicationsDao _ApplicationsDao;

        public IApplicationsDao ApplicationsDao
        {
            get { return _ApplicationsDao; }
            set { _ApplicationsDao = value; }
        }

        public bool Validate(string IdApplication, string Ip)
        {
            try
            {
                string myIp = ApplicationsDao.GetById(IdApplication).Ip;

                if (string.IsNullOrEmpty(myIp))
                    return true;
                else
                    return Ip == myIp;

            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}
